<template>
    <div class="container">
        <!-- 数据大屏展示内容 -->
        <div class="screen" ref="screen">
            <div class="top">
                <Top />
            </div>
            <div class="bottom">
                <div class="left">
                    <Tourist class="tourist" />
                    <Sex class="sex" />
                    <Age class="age" />
                </div>
                <div class="center">
                    <Map class="map" />
                    <Line class="line" />
                </div>
                <div class="right">
                    <Rank class="rank" />
                    <Year class="year" />
                    <Couter class="couter" />
                </div>
            </div>
        </div>
    </div>
</template>
<script setup lang='ts'>
// 引入顶部子组件
import Top from './components/top/index.vue'
// 引入游客子组件
import Tourist from './components/tourist/index.vue'
// 引入年龄子组件
import Age from './components/age/index.vue'
// 引入性别子组件
import Sex from './components/sex/index.vue'
// 引入地图子组件
import Map from './components/map/index.vue'
// 引入折线子组件
import Line from './components/line/index.vue'
// 引入排行榜子组件
import Rank from './components/rank/index.vue'
// 引入年度统计子组件
import Year from './components/year/index.vue'
// 引入数量子组件
import Couter from './components/couter/index.vue'


import { ref, onMounted } from 'vue'
// 获取数据大屏展示内容盒子的DOM元素
let screen = ref();
onMounted(() => {
    screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
})
// 定义大屏缩放比例
function getScale(w = 1920, h = 1080) {
    const ww = window.innerWidth / w;
    const wh = window.innerHeight / h;
    return ww < wh ? ww : wh;
}
// 监视视口变化
window.onresize = () => {
    screen.value.style.transform = `scale(${getScale()}) translate(-50%,-50%)`
}
</script>
<style lang='scss' scoped>
.container {
    width: 100vw;
    height: 100vh;
    background: url(./images/bg.png) no-repeat;
    background-size: cover;

    .screen {
        position: fixed;
        width: 1920px;
        height: 1080px;
        left: 50%;
        top: 50%;
        transform-origin: left top;

        .top {
            width: 100%;
            height: 40px;
        }

        .bottom {
            display: flex;



            .left {
                flex: 1;
                height: 1040px;
                display: flex;
                flex-direction: column;

                .tourist {
                    flex: 1;
                }

                .age {
                    flex: 1.5;
                }

                .sex {
                    flex: 1;
                }
            }

            .center {
                flex: 2;
                display: flex;
                flex-direction: column;

                .map {
                    flex: 3;
                }

                .line {
                    flex: 1;
                }
            }

            .right {
                flex: 1;
                display: flex;
                flex-direction: column;
                margin-left: 20px;

                .rank {
                    flex: 1;
                }

                .couter {
                    flex: 1.5;
                }

                .year {
                    flex: 1;
                }
            }
        }
    }
}
</style>